import { get, postJson, ApiResponseData } from '../../http.ts';
import { PageRequestData, PageResponseData } from '../common';

export interface ViewData {
    id: string
    mobile: string
    passwd: string
    salt: string
    nickname: string
    roles: string
    locked: number
    auths: string
    createTime?: string
}

export interface CreateOrUpdateData {
    id?: string
    mobile: string
    passwd: string
    salt: string
    nickname: string
    roles: string
    auths: string
}

/** 新增用户 */
export function apiAdd(data: CreateOrUpdateData) {
    const uri = "/workbench/master/user/add";
    return postJson(uri, data);
}

/** 删除用户 */
export function apiDel(id: string) {
    const uri = `/workbench/master/user/del/${id}`;
    return get(uri);
}

/** 编辑用户 */
export function apiUpt(data: CreateOrUpdateData) {
    const uri = "/workbench/master/user/edit";
    return postJson(uri, data);
}

/** 查询用户列表 */
export function apiList(
    data: PageRequestData
  ): Promise<ApiResponseData<PageResponseData<ViewData>>> {
    const uri = "/workbench/master/user/list";
    return postJson(uri, data);
  }